home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’90 / Norstad Hack / ReadMe < prev   
Text File  |  1990-06-14  |  4KB  |  83 lines

  1. The Disinfectant INIT
  2.  
  3. A hack by any other name...
  4.  
  5. John Norstad
  6. Academic Computing and Network Services
  7. Northwestern University
  8. 2129 Sheridan Road
  9. Evanston, IL 60208
  10.  
  11. Internet: jln@acns.nwu.edu
  12. Bitnet: jln@nuacc
  13. CompuServe: 76666,573
  14. AppleLink: A0173
  15.  
  16. Disinfectant 2.0 includes a new protection INIT designed for novices
  17. and others who find GateKeeper, Vaccine and other "general purpose
  18. suspicious activity monitors" just too damned complicated and obtrusive.
  19. My INIT is tiny (about 4K on disk, about 1K in the system heap), 
  20. efficient, simple, and completely unobtrusive.  It does not need to
  21. be configured, and in fact has no control panel interface at all.  It
  22. does not interfere with programming environments, installers, other
  23. anti-viral tools, or any other kind of software.  It only complains if 
  24. and when one of the known Mac viruses attacks your system.
  25.  
  26. The big disadvantage to my INIT, of course, is that it only catches 
  27. known viruses.
  28.  
  29. Despite the fact that the INIT was not written as a hack, it is one
  30. anyway.  
  31.  
  32. When an infected application is run, the viral code in the application
  33. is executed.  The INIT uses trap patches to detect the viral code at the
  34. point of its initial attack, before the virus has begun to spread or 
  35. cause any other damage.  If a virus is detected, the INIT calls the
  36. Notification Manager to alert the user, beeps ten times, and exits to
  37. shell.
  38.  
  39. Most of the trap patches (six of them in all) detect viral code by 
  40. examining locations relative to the return address in the calling
  41. routine.  This is similar (although not identical) to Apple "come-from"
  42. patches.  As with Apple's come-from patches, if any later patch is a
  43. tail patch, my patch will not work properly.  For this reason, I put a
  44. diamond character (◊) in front of the name to force it to sort to the end
  45. of the system folder, and I tell people to try to make certain that my 
  46. INIT loads last.
  47.  
  48. The WDEF virus is a special case, since it infects Finder Desktop files,
  49. not applications. The protection against the WDEF virus is particularly 
  50. sneaky.  When WDEF attacks, the INIT catches it in one of its trap
  51. patches.  It calls the Notification Manager to inform the user and beeps
  52. ten times, as usual. But it doesn't make any sense to exit to shell at
  53. this point, since it's the Finder that's running, not an infected 
  54. application.
  55.  
  56. The INIT locates the pointer to the window record on the stack,
  57. which was passed as a parameter by the Window Manager to the viral window
  58. definition function.  This window record contains a handle to the
  59. viral WDEF resource in the windowDefProc field.  The INIT replaces this 
  60. handle by a handle to the standard system WDEF 0 resource (from ROM or the
  61. system file, as appropriate).  It properly checks to see if the machine is 
  62. in 32 bit mode, because in 24 bit mode it must store only the bottom 24 
  63. bits of the handle, to avoid wiping out the window variant code in top 8 
  64. bits of the windowDefProc field.  The INIT then unwinds its own stack 
  65. frame and the viral WDEF stack frame and jumps to the standard system 
  66. WDEF 0.
  67.  
  68. This hack effectively neutralizes the WDEF virus, at least until the 
  69. window is closed and reopened (at which time my INIT catches it again, 
  70. alerts the user again, and neutralizes it again).  If I didn't do this, 
  71. the user would get an infinite sequence of extraordinarily annoying beeps
  72. and alerts.
  73.  
  74. The user can even continue to use the infected disk, without spreading
  75. the infection or causing any other damage.
  76.  
  77. Dealing with the MacMag virus is also a special case hack. In this case,
  78. I can't exit to shell, because HyperCard has already hidden the menu bar,
  79. and if I exit to shell, the user still has no menu bar in the Finder.
  80. The hack for this is similar in spirit to the WDEF hack - I mess with
  81. various pointers and locations in memory to neutralize the viral XCMD, and
  82. then I unwind the stack to just the right place and return.  
  83.